Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

riscv-peripheral: Support Core-Local Interrupt Controller (CLIC) RISC-V Privileged Architecture Extensions #195

Closed
wants to merge 6 commits into from

Conversation

hegza
Copy link

@hegza hegza commented Mar 15, 2024

Specification: https://github.com/riscv/riscv-fast-interrupt/blob/master/clic.adoc

We've made a research prototype hardware implementation of rv32emc + CLIC and have completed preliminary tests showing that this software implementation for CLIC works. However, there's a few open issues:

  • How to deal with dynamic RISC-V registers in software?
    • riscv::register::mcause dynamically allocates a different number of bits for code depending on whether riscv::mtvec::trap_mode is set to Clic = 0b11 or not.
    • The number of bits allocated for priority and level in riscv_peripheral::clic::intctl depends on the value set in riscv_peripheral::clic::smclicconfig::mnlbits.
  • We're investigating whether the fact that unaligned writes to CLIC registers fail is a problem with our HW design or a problem with RISC-V spec. This is making the current code cleanliness of the clicintx registers slightly un-ideal.
  • CLIC is not yet ratified, as is the custom around here in the RISC-V world :)
  • The CLIC spec if pretty big so we've only implemented the parts that are relevant to our use case with RTIC

@romancardenas
Copy link
Contributor

romancardenas commented Mar 15, 2024

Wooohoo! Love to see this, thanks so much :) I'll take a look at your implementation ASAP.

@perlindgren
Copy link

Beware that the specification of the CLIC is in flux. So what's in the current spec may change.

@hegza
Copy link
Author

hegza commented Mar 15, 2024

Ah, the CLIC spec has actually just a few days ago left it up to the implementor to define the MMIO layout that this PR implements. The few platforms that do implement CLIC do use this layout however so I guess it can be useful 😃 Gosh. Let's sit on it a while and see where this goes.

The CSR updates have stayed the same and we'll be implementing & testing that behavior anyway. mtvt, mnxti, mintstatus and mintthresh CSRs are used in testing already but not yet part of this PR.

@romancardenas
Copy link
Contributor

Forgot about this PR!

I'm OK with merging in master an implementation that matches the current specification and updating this implementation as the specification changes.

@hegza
Copy link
Author

hegza commented Apr 11, 2024

OK yeah, that sounds reasonable. I've been writing a journal the last 2 weeks and I was just getting back into working on the real-time system implementing this CLIC starting halfway through next week. I think I can get some update done on this within the next month.

hegza added 5 commits April 30, 2024 19:16
- smclicconfig
- clicintie, clicintip, clicintattr
This fixes an issue with unaligned writes.
- Using 32-bit writes to workaround a possible HW bug
@hegza hegza closed this May 3, 2024
@hegza hegza deleted the feat/clic branch May 3, 2024 08:54
@hegza
Copy link
Author

hegza commented May 3, 2024

Closed due to MMIO interface obsolescene. I'll re-open / link to this one once I've got the new CSR API working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants